import request from '@/utils/request'

// 没有缓存的时候，执行这个

export function axiosUrlset() {
    let defaultUrl = '192.168.2';
    if (window.location.host.indexOf(defaultUrl) != -1) {
        // 判断是否是 ip 地址
        // 百科的地址
        localStorage.baikeUrl = 'http://192.168.2.110:9528';
        // 这里是 请求的地址
        localStorage.axiosUrl = 'http://192.168.2.110:9080';
        // 这里是 魔方的地址
        localStorage.mofangUrl = 'http://192.168.2.110:4000';
        // 这里是 后台管理的地址
        localStorage.htUrl = 'http://192.168.2.110:9530';
        // 这里是 里根号的地址
        localStorage.ligenhaoUrl = 'http://192.168.2.110:9531';
        // 这里是 东伊运的地址
        localStorage.dongyiyunUrl = 'http://192.168.2.110:9532';
    } else {
        // 听说不是，那就是域名流程
        // 百科的地址
        localStorage.baikeUrl = 'http://www.inofdata.com';
        // 这里是 请求的地址
        localStorage.axiosUrl = 'http://backend.inofdata.com';
        // 这里是 魔方的地址
        localStorage.mofangUrl = 'http://mf.inofdata.com';
        // 这里是 后台管理的地址
        localStorage.htUrl = 'http://ch.inofdata.com';
        // 这里是 里根号的地址
        localStorage.ligenhaoUrl = 'http://al1.inofdata.com';
        // 这里是 东伊运的地址
        localStorage.dongyiyunUrl = 'http://al2.inofdata.com';
    }
    // console.log("yyyy", window.location.host);
}

let defaultUrlFun = () => {
        // 默认路径
        let defaultUrl = localStorage.axiosUrl;
        let yesStr = "localhost";
        if (defaultUrl.indexOf(yesStr) != -1) {
            // 因为是，需要修改成默认值
            defaultUrl = 'http://192.168.2.110:9080'
        }
        return defaultUrl
    }
    // 首页搜索接口
export function getResults(data) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/search/${data}`)
}
// 人物基本信息查询接口
export function getBasic(flag, id) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/basicInfo/${id}/${flag}`)
}
// 社交社交动态接口http://192.168.2.19:9080/socialInfo/{id}/{flag}     
export function getSocialInfo(id) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/socialInfo/${id}`)
}
// 请求社交动态折线图数据
export function getSocialChart(flag, id, startTime, endTime) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/activity/${id}/${flag}?startTime=${startTime}&endTime=${endTime}`)
}
// // 请求社交言论列表数据社交言论：http://192.168.2.19:9080/socialTalk/{id}
// export function getSocialTalk(id, accountId) {
//     return request.get(`/socialTalk/${id}?accountId=${accountId}`)
// }

// http://192.168.2.110:9080/socialTalk/{id}?accountId=?&pageCurrent=? 
export function getSocialTalk(id, accountId, pageCurrent) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/socialTalk/${id}?accountId=${accountId}&pageCurrent=${pageCurrent}`)
}

// 请求动向情报-媒体报道
export function getMedia(id, pageCurrent) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/media/${id}?pageCurrent=${pageCurrent}`)
}
// 请求动向情报-媒体报道折线图
export function getMediaActivity(flag, id, startTime, endTime) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/mediaActivity/${id}/${flag}?startTime=${startTime}&endTime=${endTime}`)
}
// 知识图谱结构数据请求
export function getRelation(id) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/relation/${id}`)
}
//实体属性：http://192.168.2.19:9080/getProperty/{id}
export function getProperty(id) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/getProperty/${id}`)
}

//媒体报道详情：http://192.168.2.19:9080/getReportDetail?articleId={articleId}
export function getReportDetail(id, source) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/getReportDetail?articleId=${id}&dataSource=${source}`)
}
//搜索提示：http://192.168.2.13:9080/keywordsTips/{keywords} 

// http://192.168.2.20:9080/basicData     参数：name(实体名称)
export function getBasicData(name) {
    let axiosUrl = defaultUrlFun();
    // console.log('我有执行：', name)
    return request.get(`${axiosUrl}/basicData?name=${name}`)
}

// http://192.168.2.20:9080/getHotNews?mediaType=     参数：name(对应的字符串)
export function getMediaType(name) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/getHotNews?mediaType=${name}`)
}

// 首页链接进来的：
export function getTalkDetail(id) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/getTalkDetail/${id}`)
}

// 相关推荐：
// http://192.168.2.10:9080/getLinkInfo/{keywords}  
export function getLinkInfo(keywords) {
    let axiosUrl = defaultUrlFun();
    return request.get(`${axiosUrl}/getLinkInfo/${keywords}`)
}



//  时间 查询：
// http://192.168.2.110:9080/socialTalk/{id}?accountId=?&pageCurrent=? 
// export function getLinkInfo(keywords) {
//     return request.get(`/getLinkInfo/${keywords}`)
// }

// 
// http://192.168.2.110:9080/achievement     参数：startTime、endTime 
// http: // 192.168.2.110:9080/download    参数：List<String> fileNames                 
// http:// 192.168.2.110:9080/readFile    参数：fileName


// export function getLinkInfo(keywords) {
//     return request.get(`/getLinkInfo/${keywords}`)
// }